let introduction = document.getElementById('learn-recommend');
introduction.setAttribute('class', introduction.getAttribute('class') + ' active');

let items = document.getElementsByClassName('item');
for (let i = 0; i < items.length; i++) {
    items[i].addEventListener('click', () => {
        // location.href=items[i].getAttribute('url');
        // location.href.reload;
        window.open(items[i].getAttribute('url'))
    })
}

let typeLinks = document.getElementsByClassName('type-link');
for (let i = 0; i < typeLinks.length; i++) {
    let url_arr = location.href.split('/');
    let param = url_arr[url_arr.length - 2]
    if (param !== 'all' && param === typeLinks[i].innerText){
        typeLinks[i].setAttribute('class', typeLinks[i].getAttribute('class') + ' active')
    }else if (param === 'all' && typeLinks[i].innerText === '所有'){
        typeLinks[i].setAttribute('class', typeLinks[i].getAttribute('class') + ' active')
    }



    if (typeLinks[i].innerText === '所有'){
        typeLinks[i].addEventListener('click', () => {
        location.href = '/learn-recommend/all';
        location.href.reload;
        })
    }else {
        typeLinks[i].addEventListener('click', () => {
        location.href = '/learn-recommend/'+typeLinks[i].innerText;
        location.href.reload;
        })
    }

}
